
/*
 * Copyright (C) 2008-2009 Archie L. Cobbs. All rights reserved.
 *
 * $Id: AbstractSchemaUpdate.java 377 2010-03-11 20:50:18Z archie.cobbs $
 */

package org.dellroad.sidekar.schema.change;

import org.dellroad.sidekar.Sidekar;
import org.dellroad.sidekar.schema.model.SchemaModel;

/**
 * Superclass for {@link SchemaChange} classes that are specific to an index in an entity.
 */
public abstract class IndexChange extends EntityChange {

    private final String indexName;

    IndexChange(String entityName, String indexName) {
        super(entityName);
        Sidekar.checkValidIndexName(indexName);
        this.indexName = indexName;
    }

    public String getIndexName() {
        return this.indexName;
    }

    @Override
    public void checkValidFor(SchemaModel schemaModel) {
        super.checkValidFor(schemaModel);
        this.checkValidIndexName(this.indexName);
        this.checkEntityExists(schemaModel, this.getEntityName());
    }
}

